package com.neusoft.SPNursingHome.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neusoft.SPNursingHome.po.CareItem;
import com.neusoft.SPNursingHome.po.LevelItem;
import com.neusoft.SPNursingHome.po.ResponseBean;
import com.neusoft.SPNursingHome.service.LevelItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/LevelItemController")
public class LevelItemController {
    @Autowired
    private LevelItemService levelItemService;

    // 给护理级别批量添加护理项目
    @PostMapping("/addLevelItem")
    public ResponseBean<Integer> addLevelItem(@RequestBody ArrayList<LevelItem> levelItems) {
        return levelItemService.addLevelItems(levelItems);
    }

    // 给护理级别移除护理项目
    @PostMapping("/deleteLevelItem")
    public ResponseBean<Integer> deleteLevelItem(@RequestBody LevelItem levelItem) {
        return levelItemService.deleteLevelItem(levelItem.getCareLevelId(), levelItem.getCareItemId());
    }

    // 查询护理级别下所有护理项目（label和status为1显示状态且开启状态）
    @GetMapping("/levelItemNoPage")
    public ResponseBean<List<CareItem>> getCareItemsByCareLevelIdNP(Integer careLevelId) {
        return levelItemService.getCareItemsByCareLevelIdNP(careLevelId);
    }

    // 查询护理级别下所有护理项目（label和status为1显示状态且开启状态）
    @GetMapping("/levelItem")
    public ResponseBean<IPage<CareItem>> getCareItemsByCareLevelId(Integer careLevelId, @RequestParam(defaultValue = "1") long page,
    @RequestParam(defaultValue = "10") long size) {
        return levelItemService.getCareItemsByCareLevelId(careLevelId, page, size);
    }
}
